#!/bin/bash


gen2(){
    ffmpeg -f lavfi -i color=c=black:s=1280x720:r=25 -vf \
    "drawtext=text='$words1':fontfile='$fontfile':fontcolor=white:fontsize=${fontsize1}:x=(w-text_w)/2:y=(h-text_h)/2:enable='between(t,0,$second1)',\
drawtext=text='$words2':fontfile='$fontfile':fontcolor=white:fontsize=${fontsize2}:x=(w-text_w)/2:y=(h-text_h)/2:enable='between(t,$second1,$((second1+second2)))'\
    " -t $((second1+second2)) -c:v libx264 -pix_fmt yuv420p "${output}.mp4"
}

fontfile="/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc"
if [ ! -f "$fontfile" ];then
    echo "[E] can not find fontfile, please install font noto font"
    sleep 5
fi

find "$fontfile"
fontsize1=80
fontsize2=120

# 中文 需要字体
words1="xxx需要的文字1"
words2="xxx需要2"
# 时长 秒
second1=2
second2=6
# 输出文件名
output=output

dir="oo"
dir="."
if [ ! -e "$dir" ];then
    mkdir "$dir"
fi

for i in $(seq 1 30);do
    words1=""
    words2="第${i}部"
    second1=0
    second2=3
    if [ "$i" -eq 1 ];then
        second2=2
    fi

    output="$dir/season$(printf "%02d" "$i")"
    gen2
done

words1=""
words2="播放下一部"
second1=0
second2=3
output="$dir/season_more"
gen2

# 只需要在 videos/目录下生成 .MP4
## 然后在 具体视频 目录下 touch  文件名即可.



